#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
	double x = 0;
	double y = 0;
	scanf("%lf",&x);
	if (x < 0 && x != -4)
	{
		y = 2 * x * x + 3 * x - 4;
		printf("%lf", y);
	}
	else if (x >= 0 && x != 1 && x != 5 && x < 10)
	{
		y = 2 * x * x - 6 * x + 5;
		printf("%lf", y);
	}
	else
	{
		y = 2 * x * x - 4 * x - 1;
		printf("%lf", y);
	}
	return 0;
}